package com.lswms.job;

import com.lswms.common.redis.RedisUtils;
import com.lswms.common.utils.MoneyUtil;
import com.lswms.common.utils.ZqDateUtil;
import com.lswms.dto.YnLotteryDTO;
import com.lswms.dto.YnSignDTO;
import com.lswms.dto.vo.resp.OrderDataListResp;
import com.lswms.entity.YnLotteryEntity;
import com.lswms.entity.YnSignEntity;
import com.lswms.service.YnLotteryService;
import com.lswms.service.YnSignService;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

import lombok.extern.slf4j.Slf4j;

import org.apache.commons.lang3.StringUtils;
import org.jsoup.helper.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


/**
 * 
 * @author Administrator
 *
 */
@Component
@Slf4j
public class LotteryTicketTasks {

    @Autowired
    private RedisUtils redisUtils;
	
    /**
     * 奖池（10s一次）
     */
    @Scheduled(cron="*/10 * * * * ?")
    public void setAmount(){
    	log.info("开始奖池（10s一次）***");
    	//双色球10秒 52000
    	int a = ThreadLocalRandom.current().nextInt(50000, 52000);
    	//排列五10秒  57800
    	int b = ThreadLocalRandom.current().nextInt(50000, 57800);
    	
    	 String a1 = (String)redisUtils.hGet("DoubleBall-1", "1");
    	 String b1 = (String)redisUtils.hGet("DoubleBall-2", "2");
    	 
    	 BigDecimal aa1 = new BigDecimal(a);
    	 BigDecimal bb1 = new BigDecimal(b);
    	 if(!StringUtil.isBlank(a1)){
    		 aa1 = new BigDecimal(a1).add(new BigDecimal(a));
    	 }
    	 if(!StringUtil.isBlank(b1)){
    		 bb1 = new BigDecimal(b1).add(new BigDecimal(b));
    	 }
    	 
    	 redisUtils.hSet("DoubleBall-1", "1",MoneyUtil.bigDecimal2String(aa1, 2));
    	 redisUtils.hSet("DoubleBall-2", "2",MoneyUtil.bigDecimal2String(bb1, 2));
    	 
    	log.info("结束奖池（10s一次）***");
    }
}
